package com.lt.flashcard.model.entity;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.google.code.morphia.annotations.Embedded;

/**
 * Store the history that use a code
 * @author ocsen
 *
 */
@Embedded
public class ProductCodeHistory {
	
	public static int STATUS_UNKNOWSET = 0; //purchased and unknow set
	public static int STATUS_DUPPLICATEDSET = -1; //already purchased this set
	public static int STATUS_NOTBLUEUPSET = -2; //this is not a blueup set

	private Long userId; //store the user id
	
	private String userName;
	
	private Date usedOn = new Date(); //use this code on date
	
	private String usedIp = "";
	
	private Map<Long, Long> products = new HashMap<Long, Long>(); //map source flashcardset to new flashcardset or the status
	
	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Date getUsedOn() {
		return usedOn;
	}

	public void setUsedOn(Date usedOn) {
		this.usedOn = usedOn;
	}

	public String getUsedIp() {
		return usedIp;
	}

	public void setUsedIp(String usedIp) {
		this.usedIp = usedIp;
	}

	/**
	 * @return the products
	 */
	public Map<Long, Long> getProducts() {
		return products;
	}

	/**
	 * @param products the products to set
	 */
	public void setProducts(Map<Long, Long> products) {
		this.products = products;
	}
	
	public void addProduct(Long source, Long target) {
		products.put(source, target);
	}
}
